package com.easy.work.view.dialog;

import android.app.Activity;
import android.app.Dialog;
import android.content.Context;
import android.content.DialogInterface;
import android.util.DisplayMetrics;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup.LayoutParams;
import android.widget.Button;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.easy.work.R;
import com.easy.work.app.AppSession;
import com.easy.work.app.BaseActivity;

/**
 * Created by admin on 2017/12/23.
 * 报名
 */
public class SignUpDialog extends Dialog {

    public SignUpDialog(Context context) {
        super(context);
    }

    public SignUpDialog(Context context, int theme) {
        super(context, theme);
    }

    public static class Builder {
        private Context context;
        private String title;
        private String message;
        private View contentView;

        public Builder(Context context) {
            this.context = context;
        }


        public Builder setContentView(View v) {
            this.contentView = v;
            return this;
        }

        /**
         * @param improveResumeListener  完善简历
         * @param continueToPostListener 继续投递
         * @return
         */
        public SignUpDialog create(final ImproveResumeListener improveResumeListener, final ContinueToPostListener continueToPostListener) {
            LayoutInflater inflater = (LayoutInflater) context
                    .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
            // instantiate the dialog with the custom Theme
            final SignUpDialog dialog = new SignUpDialog(context, R.style.AlertDialogStyle);
            View layout = inflater.inflate(R.layout.dialog_signup, null);
            DisplayMetrics dm = new DisplayMetrics();
            ((Activity) context).getWindowManager().getDefaultDisplay().getMetrics(dm);
            layout.setMinimumWidth((int) (dm.widthPixels * 0.7));
            dialog.addContentView(layout, new LayoutParams(
                    LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT));
            dialog.setContentView(layout);
            TextView tv_jixubaoming = (TextView) layout.findViewById(R.id.tv_jixubaoming);
            TextView tv_wanshanjianli = (TextView) layout.findViewById(R.id.tv_wanshanjianli);
            if (AppSession.getInstance().isResumePerfect()) {
                tv_wanshanjianli.setVisibility(View.GONE);
            }
            tv_jixubaoming.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View view) {
                    continueToPostListener.continueToPostListener(dialog);
                }
            });
            tv_wanshanjianli.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View view) {
                    improveResumeListener.improveResumeListener(dialog);
                }
            });
            return dialog;
        }
    }

    /**
     * improveResumeListener  完善简历
     */
    public interface ImproveResumeListener {
        public void improveResumeListener(SignUpDialog dialog);
    }

    /**
     * 继续投递
     */
    public interface ContinueToPostListener {
        public void continueToPostListener(SignUpDialog dialog);
    }
}